<?php
//获取环境参数 pro 线上  dev开发
header("Access-Control-Allow-Origin:*");
define('ROOT_PATH', dirname(dirname(__DIR__)));
define('APP_PATH', dirname(__DIR__));
if (empty($_SERVER['APPLICATION_ENV'])) {
    defined('YII_ENV')
    || define('YII_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'dev'));
} else {
    define('YII_ENV', $_SERVER['APPLICATION_ENV']);
}
if (!empty($_SERVER['REQUEST_URI'])) {
    $url = $_SERVER['REQUEST_URI'];
    $url = parse_url($url);
    $arr = explode('/admin', $url['path']);
    $_GET['r'] = $arr[1];
    $_SERVER['SCRIPT_NAME'] = 'wx/admin/web/index.php';
}
if (YII_ENV == 'dev' || YII_ENV == 'kaifa') {
    error_reporting(E_ALL);
    defined('YII_DEBUG') or define('YII_DEBUG', true);
    header("Access-Control-Allow-Origin:*");
} else {
    defined('YII_DEBUG') or define('YII_DEBUG', false);
}
require(ROOT_PATH . '/vendor/autoload.php');
require(ROOT_PATH . '/vendor/yiisoft/yii2/Yii.php');
require(ROOT_PATH . '/common/config/bootstrap.php');
require(APP_PATH . '/config/bootstrap.php');

$config = yii\helpers\ArrayHelper::merge(
    require(ROOT_PATH . '/common/config/main.php'),
    require(ROOT_PATH . '/common/config/appConfig/' . YII_ENV . '/main-local.php'),
    require(APP_PATH . '/config/main.php')
);
$appLiCation = new yii\web\Application($config);
$appLiCation->startTime = microtime(TRUE);//时间差
$appLiCation->defaultRoute = 'base/base/home';
$appLiCation->layout = false;
$appLiCation->run();
